package com.ruoyi.project.syl_Sxl.controller;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

import com.ruoyi.project.syl_Sxl.domain.HisOutPatientType;

import com.ruoyi.project.syl_Sxl.service.IHisOutPatientTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/syl_Sxl/patient")
public class HisOutPatientTypeController extends BaseController {

    @Autowired
    private IHisOutPatientTypeService iHisOutPatientTypeService;

    /**
     * 查询所有科室
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:patient:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisOutPatientType hisOutPatientType)
    {
        startPage();
        List<HisOutPatientType> list = iHisOutPatientTypeService.selectAll(hisOutPatientType);
        return getDataTable(list);
    }

    /**
     * 添加
     * @param
     * @return
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:patient:add')")
    @PostMapping
    public AjaxResult add(@Validated @RequestBody HisOutPatientType hisOutPatientType)
    {
        hisOutPatientType.setCreateBy(SecurityUtils.getUsername());
        return toAjax(iHisOutPatientTypeService.insertOutPatient(hisOutPatientType));
    }

    /**
     * 删除
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:patient:remove')")
    //@Log(title = "岗位管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{registerIds}")
    public AjaxResult remove(@PathVariable Long[] registerIds) {
        return toAjax(iHisOutPatientTypeService.deleteByIds(registerIds));
    }

    /**
     * 根据员工编号获取详细信息
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:patient:query')")
    @GetMapping(value = "/{registerId}")
    public AjaxResult getInfo(@PathVariable Long registerId)
    {
        return AjaxResult.success(iHisOutPatientTypeService.selectById(registerId));
    }

    /**
     * 修改员工
     */
    @PreAuthorize("@ss.hasPermi('syl_Sxl:patient:edit')")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody HisOutPatientType hisOutPatientType)
    {
        hisOutPatientType.setUpdateBy(SecurityUtils.getUsername());
        return toAjax(iHisOutPatientTypeService.updatePatient(hisOutPatientType));
    }
}
